package cn.lzy.demo.service;

import cn.lzy.demo.MyTx;
import cn.lzy.demo.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description
 * @Author lzy
 * @Date 2024/1/2 9:56
 * @Version
 **/
@Service
public class AccountService {

    @Autowired
    private AccountDao accountDao;

    @MyTx
    public void transferMoney(String from, String to, Double money) {
            accountDao.minusMoney(from, money);
            // 报错模拟代码
//            int i = 1 / 0;
            accountDao.addMoney(to, money);

    }
}
